var swiper = new Swiper(".mySwiper", {
    spaceBetween: 30,
    centeredSlides: true,
    autoplay: {
      delay: 2500,
      disableOnInteraction: false,
    },
    pagination: {
      el: ".swiper-pagination",
      clickable: true,
    },
    navigation: {
      nextEl: ".swiper-button-next",
      prevEl: ".swiper-button-prev",
    },
  });
  //API分类
function API (){
  let lis = document.querySelectorAll(".api")
  let imgs = document.querySelectorAll(".api img")
  //批量注册移入移出事件
  lis.forEach(function(li,index){
    li.addEventListener("mouseenter",function(){
      li.style.backgroundColor = "#1271ef"
      //对应索引
      let a = index + 1
      //补0
      a = a<10? "0"+a :a
      //字符串拼接
      imgs[index].src = `./images/api${a}-c.svg`
    })
    li.addEventListener("mouseleave",function(){
    li.style.backgroundColor = "white"
    let a = index + 1
    a = a<10? "0"+a :a
    imgs[index].src = `./images/api${a}.svg`
    })
  })
}
API()



  
  //助力轮播图
 function zl(){
  let contents = document.querySelectorAll(".partner .content")
  let timeId = null
  let index = 0
  timeId = setInterval(function(){
      contents[index].classList.remove("on")
        index++
        if(index==3){
          index=0
        }
        contents[index].classList.add("on")
  },2000)
  
}
zl()
// imgs[0].src = "images/more-partners-item01.svg"
// imgs[1].src = "images/more-partners-item02.svg"

 //公司logo
 function logo (){
  let imgs = document.querySelectorAll(".icon img")
  imgs.forEach(function(img,index){
    img.addEventListener("mouseenter",function(){
     let i = index + 1
     i = i<10? "0"+i :i
     imgs[index].src = `images/more-partners-item${i}.svg`
   }) 
 })
 imgs.forEach(function(im,a){
   im.addEventListener("mouseleave",function(){
     let b = a+1
     b = b<10? "0"+b :b
     imgs[a].src = `images/icon${b}.svg`
   })
 })
 }
 logo()

 //回到顶部

 function fanhui(){
  let goback = document.querySelector(".hd")

  //滚动事件
  window.addEventListener('scroll', function() {
   if(document.documentElement.scrollTop >= 1500 ) {
      goback.style.display = 'block'
   } else {
      goback.style.display = 'none'
   }
 })
 // 回到顶部
 let timeId = null
 //注册点击事件
 goback.addEventListener('click', function() {
   if(timeId){
     return
   }
   //设置定时器
     timeId = setInterval(function() {
       //每次减少的距离
         document.documentElement.scrollTop -= 150
         //到顶清除定时器
         if(document.documentElement.scrollTop <= 0) {
             clearInterval(timeId)
             timeId = null
         }
     }, 20)
 })
 }
 fanhui()





// let user = location.search.substr(7)
// let btn = document.querySelector('.btn1')
// btn.textContent = user